package com.sunye.rabbitBattle;
import org.springframework.amqp.core.*;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * amqp配置.
 */
@Configuration
public class RabbitMqBattleConfig {
    //动态路由
    private static  final String QUEUE = "seckillQueue";
    private static  final String EXCHANGE = "seckillExchange";
    private static  final String ROUTE_KEY = "seckill.#";

    @Bean
    public Queue seckillQueue(){
        return new Queue(QUEUE);
    }

    @Bean
    public TopicExchange seckillExchange(){
        return new TopicExchange(EXCHANGE);
    }

    @Bean
    public Binding seckillbinding(){
        return  BindingBuilder.bind(seckillQueue()).to(seckillExchange()).with(ROUTE_KEY);
    }
}
